<?php

class model_wishSellerAccount extends L {

    /**
     * 描述 ：分页的查询语句拼接
     * 作者 ：Zoro.Zhu
    **/
    public static function searchSql($params = array()){
        $sql = "SELECT
             `id`, `name`, `merchantId`, `cookie`, `xToken`, `state`, `vsAccount`, `updDate`, `username`, `password`
        FROM
            `wish_seller_account`
        WHERE 1";
        $sql .= " AND vsAccount = '" . core_base::getUser('name') ."'";
        $sql .= !empty($params['search']['name']) ? " AND `name` LIKE '%{$params['search']['name']}%' " : "";
        $sql .= !empty($params['search']['merchantId']) ? " AND `merchantId` = '{$params['search']['merchantId']}' " : "";
        $sql .= !empty($params['search']['state']) ? " AND `state` = '{$params['search']['state']}' " : "";
        return $sql;
    }

    /**
     * 描述 ：执行修改数据的sql
     * 作者 ：Zoro.Zhu
    **/
    public static function updateSql($data = array()){
        $sql = "UPDATE `wish_seller_account` 
        SET 
            `name` = '{$data['name']}',
            `merchantId` = '{$data['merchantId']}',
            `cookie` = '{$data['cookie']}',
            `xToken` = '{$data['xToken']}',
            `state` = '{$data['state']}',
            `vsAccount` = '{$data['vsAccount']}',
            `username` = '{$data['username']}',
            `password` = '{$data['password']}',
            `updDate` = '{$data['updDate']}'
        WHERE
            `id` = '{$data['id']}'";
        return L::sql($sql);
    }

    /**
     * 描述 ：执行插入数据的sql
     * 作者 ：Zoro.Zhu
    **/
    public static function insertSql($data = array()){
        $sql = "INSERT INTO `wish_seller_account`(
             `name`, `merchantId`, `cookie`, `xToken`, `state`, `vsAccount`, `updDate`, `username`, `password`
        ) VALUES (
             '{$data['name']}', '{$data['merchantId']}', '{$data['cookie']}', '{$data['xToken']}', '{$data['state']}', '{$data['vsAccount']}', '{$data['updDate']}', '{$data['username']}', '{$data['password']}'
        )";
        return L::sql($sql);
    }

    /**
     * 描述：根据主键获取数据
     * 作者：Zoro.Zhu
    **/
    public static function getKeyInfo($key){
        $sql = "SELECT
             `id`, `name`, `merchantId`, `cookie`, `xToken`, `state`, `vsAccount`, `updDate`, `username`, `password`
        FROM
            `wish_seller_account`
        WHERE 
            `id` = '{$key}'";
        return L::sql($sql);
    }

}